<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet">
    <title>注册页面</title>
    <style>
        body {
            background-color: #f4f4f9;
            font-family: 'Inter', sans-serif;
        }

        .card {
            transition: all 0.3s ease;
        }

        .card:hover {
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            transform: translateY(-5px);
        }

        .btn {
            transition: background-color 0.3s ease;
        }

        .btn:hover {
            background-color: #2b6cb0;
        }
    </style>
    <script>
        function saveUserInfo(event) {
            event.preventDefault(); // 阻止表单默认提交行为

            // 获取表单数据
            var username = document.getElementById("username").value;
            var email = document.getElementById("email").value;
            var password = document.getElementById("password").value;

            // 将用户信息保存到 localStorage
            localStorage.setItem("username", username);
            localStorage.setItem("email", email);
            localStorage.setItem("password", password);

            // 跳转到注册成功页面
            window.location.href = "注册成功.html";
        }

        // 在表单提交时调用 saveUserInfo 函数
        document.addEventListener("DOMContentLoaded", function() {
            document.querySelector("form").addEventListener("submit", saveUserInfo);
        });
    </script>
</head>

<body class="flex items-center justify-center min-h-screen">
    <div class="card bg-white p-8 rounded-lg shadow-md w-full max-w-md">
        <h2 class="text-2xl font-bold text-center text-gray-800 mb-6">用户注册</h2>
        <form action="注册成功.html" method="get">
            <div class="mb-4">
                <label for="username" class="block text-sm font-medium text-gray-700">用户名</label>
                <input type="text" id="username" name="username"
                    class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
                    placeholder="请输入用户名">
            </div>
            <div class="mb-4">
                <label for="email" class="block text-sm font-medium text-gray-700">邮箱</label>
                <input type="email" id="email" name="email"
                    class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
                    placeholder="请输入邮箱">
            </div>
            <div class="mb-4">
                <label for="password" class="block text-sm font-medium text-gray-700">密码</label>
                <input type="password" id="password" name="password"
                    class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
                    placeholder="请输入密码">
            </div>
            <div class="mb-6">
                <label for="confirmPassword" class="block text-sm font-medium text-gray-700">确认密码</label>
                <input type="password" id="confirmPassword" name="confirmPassword"
                    class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
                    placeholder="请再次输入密码">
            </div>
            <div class="flex justify-center">
                <button type="submit"
                    class="btn bg-blue-600 text-white py-2 px-4 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">注册</button>
            </div>
        </form>
        <div class="mt-6 text-center">
            <p class="text-sm text-gray-600">已有账号? <a href="#" class="text-blue-600 hover:underline">立即登录</a></p>
        </div>
    </div>
</body>

</html>